<?php

$servername = "localhost";
$username = "陌上";
$password = "123456";
$dbname = "陌上";


$conn = new mysqli($servername, $username, $password, $dbname);


if ($conn->connect_error) {
    die("连接失败: " . $conn->connect_error);
}


$message = $_POST['message'];


$sql = "INSERT INTO messages (message) VALUES ('$message')";

if ($conn->query($sql) === TRUE) {
    echo "留言提交成功";
} else {
    echo "错误: " . $sql . "<br>" . $conn->error;
}

$conn->close();


header("Location: welcome.php");
exit;
?>
